"use strict";
// 处理数据
var Main = {
    data: function () {
        return {
            resultData: {},
            tableData: [],
            dateValue: '',
            totalRows: 0,
            pageNum: 1,
            numPerPage: 20,
            rankYear: '',
            rankMonth: '',
            userName: '',
            rankParentTypeIndex: 0
        };
    },
    created: function () {
        this.ajaxData();
    },
    methods: {
        rankingFn: function (val) {
            this.dateValue = '';
            this.pageNum = 1;
            this.numPerPage = 20;
            this.rankYear = '';
            this.rankMonth = '';
            this.userName = '';
            this.rankParentTypeIndex = parseInt(val);
            this.ajaxData();
        },
        ajaxData: function () {
            var That = this;
            $.ajax({
                type: 'get',
                url: url,
                data: {
                    pageNum: this.pageNum,
                    numPerPage: this.numPerPage,
                    rankYear: this.rankYear || '',
                    rankMonth: this.rankMonth || '',
                    userName: this.userName || '',
                    organNbr: organNbr,
                    rankParentType: rankParentTypes[this.rankParentTypeIndex] // 接口验证字段 (农户排名)
                },
                success: function (result) {
                    this.resultData = result;
                    That.tableData = result.list; // 数据列表
                    That.totalRows = result.totalRows;
                    That.tableData = result.list;
                }
            });
            if (That.tableData.length !== 0) {
                That.tableData.map(function (item, index) {
                    item.bak3 = item.bak3 + '%';
                    item.bak2 = item.bak2 >= 100 ? '100%' : item.bak2 + '%';
                });
            }
        },
        handleCurrentChange: function (e) {
            // currentPage 改变时会触发
            this.pageNum = e + '';
            this.ajaxData();
        },
        handleSizeChange: function (e) {
            // pageSize 改变时会触发
            this.numPerPage = e + '';
            this.ajaxData();
        },
        selectDate: function (e) {
            if (e) {
                this.rankYear = e.getFullYear();
                this.rankMonth = e.getMonth() + 1;
            }
            else {
                this.rankYear = '';
                this.rankMonth = '';
            }
        },
        searchFn: function () {
            this.ajaxData();
        }
    }
};
var Ctor = Vue.extend(Main);
new Ctor().$mount('#app');
